dojo.provide("mydojo.test.declare.Shape");
dojo.declare("Shape",null,{
	color:0,
	constructor:function(){
		console.log("Shape construcotr is called");
	},
	setColor:function(color){
		this.color = color;	
	}
})


dojo.declare("Circle",Shape,{
	radius:0,
	constructor:function(radius){
		console.log("Circle construcotr is called");
		this.radius = radius || this.radius;
	},
	setRadius:function(radius){
		this.radius = radius;
	},
	area:function(){
		console.log("Circle area is called");
		return Math.PI * this.radius * this.radius;
	}
});
dojo.declare("Rangle",Shape,{
	length:0,
	width:0,
	constructor:function(l,w){
		console.log("Rangle construcotr is called");
		this.length = l || this.length;
		this.width = w || tihs.width;
	},
	setLength: function(l){
		this.length = l;
	},
	setWidth: function(w){
		this.width = w;
	},
	area: function(){
		return this.width * this.length;
	}
});
dojo.declare("Position",null,{
	x:0,
	y:0,
	constructor:function(x,y){
		console.log("Position construcotr is called"+x+"-"+y);
		this.x = x || this.x;
		this.y = y || this.y;
		
	},
	area:function(){
		console.log("Position area is zero");
	},
	setPosition:function(x,y){
		this.x = x;
		this.y = y;
	},
	move:function(deltax,deltay){
		this.x += deltax;
		this.y += deltay;
	}
});
dojo.declare("PositionCircle",[Circle,Position],{
	constructor:function(radius,x,y){
		console.log("PositionCircle construcotr is called");
		this.setPosition(x,y);
	}
})

dojo.declare("Base" , null, {
	preamble:function(){
		return [1,2];
	},
	constructor: function() {
		console.log("Base constructor is called--"+dojo._toArray(arguments));
		this.args = {base_args: dojo._toArray(arguments)};
	},
	postscript: function(args){
		console.log(dojo.toJson(dojo._toArray(arguments), true));
		console.log("Base postscript is called");
		console.log(dojo.toJson(this.args, true));
	}
});
dojo.declare("Subclass" , Base, {
	constructor: function() {
		console.log("Subclass constructor is called"+dojo._toArray(arguments));
		this.args.subclass_args= dojo._toArray(arguments);
	},
	preamble: function(args) {
	//the superclass (Base) only gets the first three arguments...
		console.log("preamble  is called");
		return dojo._toArray(arguments).slice(0, 3);
	},
	postscript: function(){
		console.log("In Subclass's postscript." );
		this.inherited(arguments);
	}
});

